package com.wwy.util;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

public final class JacksonUtil {

    public static ObjectMapper objectMapper = new ObjectMapper();

    public JacksonUtil() {
    }

    public static <T> T readValue(String jsonStr, Class<T> valueType) {
        try {
            return objectMapper.readValue(jsonStr, valueType);
        } catch (Exception var3) {
            throw new RuntimeException("JacksonUtil.readValue(String,Class<T>)执行异常", var3);
        }
    }

    public static <T> T readValue(String jsonStr, TypeReference<T> valueTypeRef) {
        try {
            return objectMapper.readValue(jsonStr, valueTypeRef);
        } catch (Exception var3) {
            throw new RuntimeException("JacksonUtil.readValue(String,TypeReference<T>)执行异常", var3);
        }
    }

    /** @deprecated */
    public static String toJSon(Object object) {
        try {
            return objectMapper.writeValueAsString(object);
        } catch (Exception var2) {
            throw new RuntimeException("JacksonUtil.toJSon执行异常", var2);
        }
    }

    public static String toJson(Object object) {
        try {
            return objectMapper.writeValueAsString(object);
        } catch (Exception var2) {
            throw new RuntimeException("JacksonUtil.toJSon执行异常", var2);
        }
    }
}
